{% extends 'base.html' %}
{% block legend %}Dubbo接口测试工具{% endblock %}
{% block content %}
    <blockquote class="layui-elem-quote">可以直接测试dubbo接口</blockquote>

    <div class="layui-row">
        <div class="layui-col-md6">
            {% if  info %}
                <form action="/dubbo/invoke" class="layui-form layui-form-pane" method="POST">

                    <div class="layui-form-item">
                        <label class="layui-form-label">地址</label>
                        <div class="layui-input-block">
                            <label>
                                <input type="text" autocomplete="off"
                                       placeholder="请输入地址信息" class="layui-input layui-font-gray"
                                       value="{{ info['host'] }}" readonly>
                            </label>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">端口</label>
                        <div class="layui-input-block">
                            <label>
                                <input type="text" autocomplete="off"
                                       placeholder="请输入端口信息" class="layui-input layui-font-gray"
                                       value="{{ info['port'] }}" readonly>
                            </label>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">服务</label>
                        <div class="layui-input-block">
                            <label>
                                <input type="text" name="service" autocomplete="off"
                                       placeholder="请输入服务信息" class="layui-input layui-font-gray" readonly
                                       value="{{ info['service'] }}">
                            </label>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">接口</label>
                        <div class="layui-input-block">
                            <label>
                                <select name="method" lay-search>
                                    <option value=""></option>
                                    {% for method in info['method'] %}
                                        {% if req %}
                                            {% if req['method']==method %}
                                                <option name="method" selected>{{ req['method'] }}</option>
                                            {% else %}
                                                <option name="method">{{ method }}</option>
                                            {% endif %}
                                        {% else %}
                                            <option name="method">{{ method }}</option>
                                        {% endif %}
                                    {% endfor %}
                                </select>
                            </label>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">参数</label>
                        <div class="layui-input-block">
                            <label>
                        <textarea type="text" name="args" autocomplete="off"
                                  placeholder="请输入请求参数" class="layui-textarea layui-font-red"
                                  style="margin-top: 0px; margin-bottom: 0px;">{{ req['args'] if req }}</textarea>
                            </label>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <div class="layui-btn-container">
                            <button type="submit" class="layui-btn">提交</button>
                            <a href="/">
                                <button type="button" class="layui-btn layui-bg-gray">返回</button>
                            </a>
                        </div>
                    </div>

                </form>

            {% else %}
                <form class="layui-form layui-form-pane" method="POST">

                    <div class="layui-form-item">
                        <label class="layui-form-label">服务API</label>
                        <div class="layui-input-block">
                            <label>
                                <select name="service" lay-search required>
                                    <option value="">请选择服务API</option>
                                    {% for service in services %}
                                        <option value="{{ service }}">{{ service }}</option>
                                    {% endfor %}
                                </select>
                            </label>
                        </div>
                    </div>

                    <div class="layui-btn-container">
                        <button type="submit" class="layui-btn">搜索</button>
                    </div>

                </form>

            {% endif %}

        </div>

        <div class="layui-col-md6">
            {% if res %}
                <pre class="layui-code">{{ res }}</pre>
            {% endif %}
        </div>
    </div>
    <script src="/static/js/dubbo.js"></script>
{% endblock %}